<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Http\Model\DailyStatisticsModel;

class DailyStatistics extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'dailyStatistics';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '每日统计';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        set_time_limit(0);
        $yesterdayDate = date('Y-m-d', strtotime("-1 days"));
        $yesterdayStart = strtotime($yesterdayDate.' 00:00:00');
        $yesterdayEnd = strtotime($yesterdayDate.' 23:59:59');
        do {
            $dailyStatisticsModel = new DailyStatisticsModel();
            //每日统计
            $dailyStatisticsModel->statisticalData($yesterdayStart, $yesterdayEnd);
            //每日房间消费统计
            $dailyStatisticsModel->statisticalDayRoom($yesterdayStart, $yesterdayEnd);
        } while (false);

    }

}